#!/bin/bash

mkdir -p build 
if [ $# -gt 0 ] ; then
  echo "build project for debug"
  nasm -f elf64 -F dwarf src/uint128_div_v1.asm -o build/uint128_div_v1.o
  nasm -f elf64 -F dwarf src/uint128_div_v2.asm -o build/uint128_div_v2.o
  gcc       -c -ggdb -O0 src/uint128.c          -o build/uint128.c.o
  gcc       -c -ggdb -O0 src/uint128_test.c     -o build/test.o
  gcc  build/uint128.c.o build/uint128_div_v1.o build/uint128_div_v2.o build/test.o -o test
else
  nasm -f elf64 src/uint128_div_v1.asm -o build/uint128_div_v1.o
  nasm -f elf64 src/uint128_div_v2.asm -o build/uint128_div_v2.o
  gcc -c -O2    src/uint128.c          -o build/uint128.c.o
  gcc -c -O2    src/uint128_test.c     -o build/test.o
  gcc build/uint128.c.o build/uint128_div_v1.o build/uint128_div_v2.o build/test.o -o test
fi